<template>
  <div class="recomd-bigbox">
    <div class="warpper">
      <div class="recomd-title">每日推荐</div>
      <ul>
        <router-link
          tag="li"
          :to="{
            name: 'Details',
            params: {
              id: item.id,
              name: item.name,
              price: item.price,
              height: item.height,
              weight: item.weight,
              img: encodeURIComponent(item.img),
              age: item.age,
              phone: item.phone,
              remark: item.remark,
              introduction: item.introduction,
            },
          }"
          class="recomd-box"
          v-for="item in recommendData"
          :key="item.id"
        >
          <img :src="item.img" alt="" />
          <p>
            <span>{{ item.name }}</span> <span>价格：{{ item.price }}</span>
          </p>
          <div class="star">{{ item.type }}</div>
        </router-link>
      </ul>
    </div>
    <div class="ranking">
      <p class="ranking-title"><span>|</span> 排行榜</p>
      <p><span>排行</span> <span>主持人</span> <span>订单量</span></p>
      <ul class="ranking-content">
        <li
          class="ranking-info"
          v-for="(item, index) in hostList"
          :key="item.id"
        >
          <p class="ranking-rank">{{ index + 1 }}</p>
          <p class="ranking-name">{{ item.name }}</p>
          <p class="ranking-num">{{ item.order }}</p>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import api from "../../api/";
export default {
  name: "DateRecom",
  data() {
    return {
      recommendData: {},
      hostList: {},
    };
  },
  computed: {},
  methods: {
    // filtration(arr) {
    //   return arr.filter((item) => {
    //     if (item.order != "") {
    //       return true;
    //     }
    //   });
    // },
  },
  mounted() {
    api.getRecommendation().then((res) => {
      if (res.data.status === 200) {
        // let arr = res.data.list.splice(0, 10);
        // this.hostList = arr.sort((ele1, ele2) => {
        //   return (ele1.order - ele2.order) * -1;
        // });
        let arr = res.data.list.sort((ele1, ele2) => {
          return (ele1.order - ele2.order) * -1;
        });

        let role = localStorage.getItem("wedding-role");
        if (role == "新人") {
          for (let ele of res.data.list) {
            // console.log(ele);
            ele.price = ele.price * 3;
          }
        }

        this.recommendData = res.data.list;
        this.hostList = arr.splice(0, 10);
      }
    });
  },
};
</script>

<style scoped lang="less" >
.recomd-bigbox {
  position: relative;
  .warpper {
    overflow: hidden;
    padding: 10px;
    background: #fff;

    .recomd-title {
      font-size: 20px;
      font-weight: 600;
      margin: 10px 10px;
    }
    .recomd-box {
      position: relative;
      float: left;
      width: 180px;
      height: 220px;
      margin: 10px 10px;
      img {
        width: 180px;
        height: 220px;
      }
      p {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 14px;
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
        span {
          margin-left: 20px;
        }
      }
      .star {
        position: absolute;
        top: 0;
        left: 0;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background-color: #ffa500;
        color: #fff;
        text-align: center;
        line-height: 50px;
        font-weight: 500;
        font-size: 14px;
      }
    }
  }
  .ranking {
    position: absolute;
    top: 0;
    left: 120px;
    background: #ffa500;
    color: #fff;
    width: 150px;
    text-align: center;
    padding: 10px;
    .ranking-title {
      font-size: 20px;
      font-weight: 600;
      padding: 5px 10px;
      border: 2px solid #fff;
      span {
        font-size: 16px;
        margin-right: 10px;
      }
    }
    .ranking-info {
      overflow: hidden;
      p {
        float: left;
        box-sizing: border-box;
        font-size: 16px;
        // width: 80px;
        padding: 5px;
        border: 1px solid #fff;
      }
      .ranking-rank {
        width: 30px;
      }
      .ranking-name {
        width: 70px;
      }
      .ranking-num {
        width: 50px;
      }
    }
  }
}
</style>